package com.cokoyan.game.afts;

import java.util.Random;

import com.cokoyan.game.afts.GraphsEnemis.Type;

public class DATA {
	public static final Random rnd = new Random(System.currentTimeMillis());
	
	public static final int TIMER_TOUCHTIME = 20;
	public static final int SPAWN_X = 530;
	
	//Methode de detection rapide des collisions
	public static boolean isCollided(int x1, int y1, int with1, int height1,
									 int x2, int y2, int with2, int height2){
		int centerX1 = x1 + (with1/2);
		int centerX2 = x2 + (with2/2);
		if(Math.abs(centerX1-centerX2)<(with1/2+with2/2)){
			int centerY1 = y1 + (height1/2);
			int centerY2 = y2 + (height2/2);
			if(Math.abs(centerY1-centerY2)<(height1/2+height2/2)){
				return true;
			}
		}
		return false;
	}
	
	
	
	
	public static int getNbEnemisByLevel(int level){
		int nb = 0;
		
		if(level < 5){
			nb = 3;
		}else if(level < 10){
			nb = 4;
		}else if(level < 15) {
			nb = 5;
		}else if(level < 20) {
			nb = 6;
		}else if(level < 25) {
			nb = 7;
		}else if(level < 30) {
			nb = 8;
		}else if(level < 35) {
			nb = 9;
		}else if(level < 40) {
			nb = 10;
		}else{
			nb = 11;
		}
		
		return nb;
	}
	
	
	public static int getSpeedEnemyByLevel(int level){
		int nb = 0;
		
		if(level < 5){
			nb = 2;
		}else if(level < 15) {
			nb = 3;
		}else if(level < 25) {
			nb = 4;
		}else if(level < 35) {
			nb = 5;
		}else{
			nb = 6;
		}
		
		return nb;
	}
	
	
	public static int getShootCadenceByLevel(int level){
		int nb = 0;
		
		if(level < 5){
			nb = 3000+DATA.rnd.nextInt(2000);
		}else if(level < 10){
			nb = 2900+DATA.rnd.nextInt(2000);
		}else if(level < 15) {
			nb = 2800+DATA.rnd.nextInt(2000);
		}else if(level < 20) {
			nb = 2700+DATA.rnd.nextInt(2000);
		}else if(level < 25) {
			nb = 2600+DATA.rnd.nextInt(2000);
		}else if(level < 30) {
			nb = 2500+DATA.rnd.nextInt(2000);
		}else if(level < 35) {
			nb = 2400+DATA.rnd.nextInt(2000);
		}else if(level < 40) {
			nb = 2300+DATA.rnd.nextInt(2000);
		}else if(level < 45) {
			nb = 2200+DATA.rnd.nextInt(2000);
		}else if(level < 50) {
			nb = 2100+DATA.rnd.nextInt(2000);
		}else if(level < 55) {
			nb = 2000+DATA.rnd.nextInt(2000);
		}else if(level < 60) {
			nb = 1900+DATA.rnd.nextInt(2000);
		}else if(level < 65) {
			nb = 1800+DATA.rnd.nextInt(2000);
		}else if(level < 70) {
			nb = 1700+DATA.rnd.nextInt(2000);
		}else if(level < 75) {
			nb = 1600+DATA.rnd.nextInt(2000);
		}else if(level < 80) {
			nb = 1500+DATA.rnd.nextInt(2000);
		}else if(level < 85) {
			nb = 1400+DATA.rnd.nextInt(2000);
		}else if(level < 90) {
			nb = 1300+DATA.rnd.nextInt(2000);
		}else if(level < 95) {
			nb = 1200+DATA.rnd.nextInt(2000);
		}else if(level < 100) {
			nb = 1100+DATA.rnd.nextInt(2000);
		}else if(level < 105) {
			nb = 1000+DATA.rnd.nextInt(2000);
		}else if(level < 110) {
			nb = 1000+DATA.rnd.nextInt(1800);
		}else if(level < 115) {
			nb = 1000+DATA.rnd.nextInt(1600);
		}else if(level < 120) {
			nb = 1000+DATA.rnd.nextInt(1600);
		}else if(level < 125) {
			nb = 1000+DATA.rnd.nextInt(1400);
		}else if(level < 130) {
			nb = 1000+DATA.rnd.nextInt(1200);
		}else if(level < 135) {
			nb = 1000+DATA.rnd.nextInt(1000);
		}else if(level < 140) {
			nb = 1000+DATA.rnd.nextInt(800);
		}else{
			nb = 1000+DATA.rnd.nextInt(600);
		}
		
		
		return nb;
	}
	
	public static Type getEnemyType(int level){
		int nb = 0;
		if(level < 5){
			nb = DATA.rnd.nextInt(10);
		}else if(level < 10){
			nb = DATA.rnd.nextInt(11);
		}else if(level < 15) {
			nb = DATA.rnd.nextInt(12);
		}else if(level < 20) {
			nb = DATA.rnd.nextInt(13);
		}else if(level < 25) {
			nb = DATA.rnd.nextInt(14);
		}else if(level < 30) {
			nb = DATA.rnd.nextInt(15);
		}else if(level < 35) {
			nb = DATA.rnd.nextInt(16);
		}else if(level < 40) {
			nb = DATA.rnd.nextInt(17);
		}else if(level < 45) {
			nb = DATA.rnd.nextInt(18);
		}else if(level < 50) {
			nb = DATA.rnd.nextInt(19);
		}else if(level < 55) {
			nb = DATA.rnd.nextInt(20);
		}else if(level < 60) {
			nb = DATA.rnd.nextInt(21);
		}else if(level < 65) {
			nb = DATA.rnd.nextInt(22);
		}else if(level < 70) {
			nb = DATA.rnd.nextInt(23);
		}else if(level < 75) {
			nb = DATA.rnd.nextInt(24);
		}else if(level < 80) {
			nb = DATA.rnd.nextInt(25);
		}else if(level < 85) {
			nb = DATA.rnd.nextInt(26);
		}else if(level < 90) {
			nb = DATA.rnd.nextInt(27);
		}else if(level < 95) {
			nb = DATA.rnd.nextInt(28);
		}else if(level < 100) {
			nb = DATA.rnd.nextInt(29);
		}else if(level < 105) {
			nb = DATA.rnd.nextInt(30);
		}else if(level < 110) {
			nb = DATA.rnd.nextInt(31);
		}else if(level < 115) {
			nb = DATA.rnd.nextInt(32);
		}else if(level < 120) {
			nb = DATA.rnd.nextInt(33);
		}else if(level < 125) {
			nb = DATA.rnd.nextInt(34);
		}else if(level < 130) {
			nb = DATA.rnd.nextInt(35);
		}else if(level < 135) {
			nb = DATA.rnd.nextInt(36);
		}else if(level < 140) {
			nb = DATA.rnd.nextInt(37);
		}else{
			nb = DATA.rnd.nextInt(38);
		}
		
		if(nb<10){
			return Type.basic;
		}else if(nb<20){
			return Type.speed;
		}else{
			return Type.strong;
		}
	}


	public static long getAsteroidRespawnCadence(int level) {
		long nb = 0;
		nb = 10000-level*100;
		if(nb<2000){
			nb = 2000;
		}
		return nb;
	}
	
	public static int getAsteroidSpeed(int level) {
		int nb = 0;
		nb = 2+(level/15);
		if(nb>13){
			nb = 13;
		}
		return nb;
	}
	
}
